<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
    <!-- 上传图片css -->
    <link rel="stylesheet" href="../lib/upload/upload.css" media="all">
    <!-- 百度地图css -->
    <link rel="stylesheet" href="http://api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.css" />
    <!-- <style>       
        .uploader-list {
        	height:122px;
            margin-left: -15px;
        }
 
        .uploader-list .info {
            position: relative;
            margin-top: -25px;
            background-color: black;
            color: white;
            filter: alpha(Opacity=80);
            -moz-opacity: 0.5;
            opacity: 0.5;
            width: 100px;
            height: 25px;
            text-align: center;
            display: none;
        }
 
        .uploader-list .handle {
            position: relative;
            background-color: black;
            color: white;
            filter: alpha(Opacity=80);
            -moz-opacity: 0.5;
            opacity: 0.5;
            width: 118px;
            text-align: right;
            height: 18px;
            margin-bottom: -18px;
            display: none;
        }
 
        .uploader-list .handle i {
            margin-right: 5px;
        }
 
        .uploader-list .handle i:hover {
            cursor: pointer;
        }
 
        .uploader-list .file-iteme {
            margin: 12px 0 0 15px;
            padding: 1px;
            float: left;
        }
    </style> -->
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">      
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">单行输入框</label>
                <div class="layui-input-block">
                    <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">验证必填项</label>
                <div class="layui-input-block">
                    <input type="text" name="username" lay-verify="required" lay-reqtext="用户名是必填项，岂能为空？" placeholder="请输入" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">验证手机</label>
                    <div class="layui-input-inline">
                        <input type="tel" name="phone" lay-verify="required|phone" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">验证邮箱</label>
                    <div class="layui-input-inline">
                        <input type="text" name="email" lay-verify="email" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">多规则验证</label>
                    <div class="layui-input-inline">
                        <input type="text" name="number" lay-verify="required|number" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">验证日期</label>
                    <div class="layui-input-inline">
                        <input type="text" name="date" id="date" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">验证链接</label>
                    <div class="layui-input-inline">
                        <input type="tel" name="url" lay-verify="url" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">验证身份证</label>
                <div class="layui-input-block">
                    <input type="text" name="identity" lay-verify="identity" placeholder="" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">自定义验证</label>
                <div class="layui-input-inline">
                    <input type="password" name="password" lay-verify="pass" placeholder="请输入密码" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">请填写6到12位密码</div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">范围</label>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input type="text" name="priceMin" placeholder="￥" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid">-</div>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input type="text" name="priceMax" placeholder="￥" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">单行选择框</label>
                <div class="layui-input-block">
                    <select name="interest" lay-filter="aihao">
                        <option value=""></option>
                        <option value="0">写作</option>
                        <option value="1">阅读</option>
                        <option value="2">游戏</option>
                        <option value="3">音乐</option>
                        <option value="4">旅行</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">                
                <div class="layui-inline">
                    <label class="layui-form-label">搜索选择框</label>
                    <div class="layui-input-inline">
                        <select name="modules" lay-verify="required" lay-search="">
                            <option value="">直接选择或搜索选择</option>
                            <option value="1">layer</option>
                            <option value="2">form</option>
                            <option value="3">layim</option>
                            <option value="4">element</option>
                            <option value="5">laytpl</option>
                            <option value="6">upload</option>
                            <option value="7">laydate</option>
                            <option value="8">laypage</option>
                            <option value="9">flow</option>
                            <option value="10">util</option>
                            <option value="11">code</option>
                            <option value="12">tree</option>
                            <option value="13">layedit</option>
                            <option value="14">nav</option>
                            <option value="15">tab</option>
                            <option value="16">table</option>
                            <option value="17">select</option>
                            <option value="18">checkbox</option>
                            <option value="19">switch</option>
                            <option value="20">radio</option>
                        </select>
                    </div>
                </div>
            </div>
            
            <!--<div class="layui-form-item" id="area-picker">
                <div class="layui-form-label">网点地址</div>
                <div class="layui-input-inline" style="width: 200px;">
                    <select name="province" class="province-selector" data-value="" lay-filter="province-1">
                        <option value="">请选择省</option>
                    </select>
                </div>
                <div class="layui-input-inline" style="width: 200px;">
                    <select name="city" class="city-selector" data-value="" lay-filter="city-1">
                        <option value="">请选择市</option>
                    </select>
                </div>
                <div class="layui-input-inline" style="width: 200px;">
                    <select name="county" class="county-selector" data-value="" lay-filter="county-1">
                        <option value="">请选择区</option>
                    </select>
                </div>
            </div>-->
			
            <div class="layui-form-item" id="area-picker">
		        <label class="layui-form-label required">网点地址</label>
		        <div class="layui-input-inline">
			      	<select name="quiz1" id="quizarea1" lay-search="" lay-filter="quizarea1" lay-verify="required" lay-reqtext="请选择省份">
			      	</select>
			    </div>
			    <div class="layui-input-inline">
			      <select name="quiz1" id="quizarea2" lay-search="" lay-filter="quizarea2" lay-verify="required" lay-reqtext="请选择市">
			      </select>
			    </div>
			    <div class="layui-input-inline">
			      <select name="quiz1" id="quizarea3" lay-search="" lay-filter="quizarea3" lay-verify="required" lay-reqtext="请选择县/区">
			      </select>
			    </div>
			    <div class="layui-input-inline">
			      <select name="quiz1" id="quizarea4" lay-search="" lay-filter="quizarea4" lay-verify="required" lay-reqtext="请选择乡镇/街道">
			      </select>
			    </div>
		    </div>
		    <div class="layui-form-item">
		        <label class="layui-form-label required">经纬度</label>
		        <div class="layui-input-block" style="width: 190px;">
		            <input type="text" name="coordinates" id="coordinates" lay-verify="required" placeholder="请输入经纬度"
						   autocomplete="off" class="layui-input" readonly="readonly">
		        </div>
		    </div>
            
			<div class="layui-form-item">
                <label class="layui-form-label">多选下拉框</label>
                <div class="layui-input-inline">
                    <input type="text" placeholder="请输入" autocomplete="off" class="layui-input" id="tableSelect" value="" ts-selected="">
                </div>
                <input type="hidden" name="selectTable" id="selectTable"/>
                <input type="hidden" name="tableSelect" id="tableSelects"/>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">复选框</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="like1" title="写作">
                    <input type="checkbox" name="like2" title="阅读">
                    <input type="checkbox" name="like3" title="游戏">
                </div>
            </div>

            <div class="layui-form-item" pane="">
                <label class="layui-form-label">原始复选框</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="like4" lay-skin="primary" title="写作">
                    <input type="checkbox" name="like5" lay-skin="primary" title="阅读">
                    <input type="checkbox" name="like6" lay-skin="primary" title="游戏">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">开关-默认关</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="close" lay-skin="switch" lay-text="ON|OFF">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">开关-默认开</label>
                <div class="layui-input-block">
                    <input type="checkbox" checked="" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">单选框</label>
                <div class="layui-input-block">
                    <input type="radio" name="sex" value="男" title="男">
                    <input type="radio" name="sex" value="女" title="女">
                    <input type="radio" name="sex" value="禁" title="禁用">
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">普通文本域</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入内容" class="layui-textarea" name="content"></textarea>
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">富文本编辑</label>
                <div class="layui-input-block">
                     <div id="editor"></div>
                </div>
            </div>
            <!-- <div class="layui-form-item" style="padding-left:110px">
			   <div class="layui-upload layui-inline">	   		
				    <div class="layui-upload-list uploader-list">
					    <div id="" class="file-iteme">
					    	<div class="handle" id="handle1"><i class="layui-icon layui-icon-delete"></i></div>
					        <img class="layui-upload-img" src="" onerror="this.src='../images/img.png'" id="demo1" style="width:118px;height:118px">
					    </div>
				    </div>
				    <button type="button" class="layui-btn" id="test1" style="width:119px;">上传图片</button>
				    <input type="hidden" id="demoText1" />
				</div>
				<div class="layui-upload layui-inline">
				    <div class="layui-upload-list uploader-list">
				       <div id="" class="file-iteme">
					    	<div class="handle" id="handle2"><i class="layui-icon layui-icon-delete"></i></div>
					        <img class="layui-upload-img" src=""  id="demo2" onerror="this.src='../images/img.png'" style="width:118px;height:118px">
					    </div>
				    </div>
				    <button type="button" class="layui-btn" id="test2" style="width:119px;">上传图片</button>
				    <input type="hidden" id="demoText2" />
				</div>
				<div class="layui-upload layui-inline">
				    <div class="layui-upload-list uploader-list">
				        <div id="" class="file-iteme">
					    	<div class="handle" id="handle3"><i class="layui-icon layui-icon-delete"></i></div>
					        <img class="layui-upload-img" src=""  id="demo3" onerror="this.src='../images/img.png'" style="width:118px;height:118px">
					    </div>
				    </div>
				    <button type="button" class="layui-btn" id="test3" style="width:119px;">上传图片</button>
				    <input type="hidden" id="demoText3" />
				</div>
			</div> -->
			<div class="layui-form-item">
				<label class="layui-form-label">上传图片</label>
				<div class="case" style="width:1000px;padding-left:110px;">
					<!-- 上传图片属性参数 -->
					<!-- data-height：图片上传压缩最大高度，0则根据宽度等比例压缩，默认0 -->
					<!-- data-width：图片上传压缩最大宽度，0则根据高度等比例压缩，默认0 -->
					<!-- data-type：允许上传文件的扩展名，多个扩展名用逗号分割，支持非图片格式的文件上传，默认png,jpg,jpeg,gif -->
					<!-- data-file：上传提交服务器的表单名，默认file -->
					<!-- data-name：最终表单提交图片路径的表单名，默认upload -->
					<!-- action：服务器接收上传文件的地址，服务器需返回{"code":1,"msg":"/upload/1.jpg"}的JSON字符串，code为上传状态，1为成功，0为失败，msg为成功的文件路径或失败原因提示！ -->
					<!-- data-num：最多可以上传多少个文件，如为1，上传插件为单个文件上传样式，默认10  -->
					<!-- data-size：文件上传单个文件最大容量，图片不传不受该属性限制，默认20480  -->
					<!-- data-value：已经上传成功的文件名，多个文件用英文逗号分割，默认null  -->
	 				<div class="upload" action='../sysTemplate/imageUpload' data-num=4 data-file='image' data-name='pic' id='case'></div>
				</div>
			</div>					      
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                    <button class="layui-btn layui-btn-normal" id="cancel">取消</button>
                </div>
            </div>
        </form>
    </div>
    <div id="maplocation" style="width:500px;height:500px;display: none;"></div>
</div>
<!-- 上传图片jquery -->
<script src="../lib/upload/jquery.min.js" charset="utf-8"></script>
<script src="../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<!-- 上传图片js -->
<script src="../lib/upload/jquery.upload.min.js" charset="utf-8"></script>
<!-- 百度地图js -->
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=bjYCivmvHKETZXCaBdDeblvc2M0vgfwD"></script>
<script type="text/javascript" src="http://api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.js"></script>
<script>
    layui.use(['form', 'layedit', 'laydate','layarea','wangEditor','upload','tableSelect'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate
            , layarea = layui.layarea
            , upload=layui.upload
            , wangEditor = layui.wangEditor
            , tableSelect = layui.tableSelect
            ,$ = layui.$;

        var uploadurl=localStorage.getItem("uploadurl");
        //日期
        laydate.render({
            elem: '#date'
        });
        
       /*  layarea.render({
            elem: '#area-picker',
            change: function (res) {
                //选择结果
                console.log(res);
            }
        }); */
      //初始化地区联动框
        layer.ready(function(){
        	LayuiCreateSelectArea("quizarea1","../area/getAreaList","","1");
        });
      //初始化表单，要加上，不然刷新部分组件可能会不加载
        form.render();       
        var iframeIndex = parent.layer.getFrameIndex(window.name);

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
            title: function (value) {
                if (value.length < 5) {
                    return '标题至少得5个字符啊';
                }
            }
            , pass: [
                /^[\S]{6,12}$/
                , '密码必须6到12位，且不能出现空格'
            ]
            , content: function (value) {
                layedit.sync(editIndex);
            }
        });

        //监听指定开关
        form.on('switch(switchTest)', function (data) {
            layer.msg('开关checked：' + (this.checked ? 'true' : 'false'), {
                offset: '6px'
            });
        });

        //监听提交
        form.on('submit(demo1)', function (data) {
        	/* //图片传值
        	var demoText1=$("#demoText1").val();
      	    var demoText2=$("#demoText2").val();
      	    var demoText3=$("#demoText3").val();
      	    var picurl="";	    
      	    
	      	if(demoText1!=''&&demoText1!=null&&demoText1!=undefined){
	      		picurl=demoText1;
	      	}
	      	if(demoText2!=''&&demoText2!=null&&demoText2!=undefined){
	      		if(picurl==""){
	      			picurl=demoText2;
	      		}else{
	      			picurl=picurl+","+demoText2;
	      		}
	      	}
	      	if(demoText3!=''&&demoText3!=null&&demoText3!=undefined){
	      		if(picurl==""){
	      			picurl=demoText3;
	      		}else{
	      			picurl=picurl+","+demoText3;
	      		}
	      	}
	      	data.field.pic=picurl;
	      		      	
	      	var vic=$("#vic").val();
	      	var vicurl="";
	      	if(vic!=''&&vic!=null&&vic!=undefined){
	      		vicurl=vic;
	      	}
	      	data.field.vic=vicurl; */
	      	
        	demoText1=$("#quizarea1").val();
	   	 	demoText2=$("#quizarea2").val();
	   	 	demoText3=$("#quizarea3").val();
	   	 	demoText4=$("#quizarea4").val();
	   	 	var area="";
		   	if(demoText1!=''&&demoText1!=null&&demoText1!=undefined){
		   		area=demoText1;
		   	}
		   	if(demoText2!=''&&demoText2!=null&&demoText2!=undefined){
		   		if(area==""){
		   			area=demoText2;
		   		}else{
		   			area=area+","+demoText2;
		   		}
		   	}
		   	if(demoText3!=''&&demoText3!=null&&demoText3!=undefined){
		   		if(area==""){
		   			area=demoText3;
		   		}else{
		   			area=area+","+demoText3;
		   		}
		   	}
		   	if(demoText4!=''&&demoText4!=null&&demoText4!=undefined){
		   		if(area==""){
		   			area=demoText4;
		   		}else{
		   			area=area+","+demoText4;
		   		}
		   	}
		   	data.field.area=area;
	      	
        	//富文本传值
        	editor.txt.html(content);
            var content = editor.txt.html();
        	data.field.info=content;
        	//多选下拉参数
        	data.field.selectTable=$("#selectTable").val().substring(1);
        	data.field.tableSelect=$("#tableSelects").val().substring(1);
        	
        	$.ajax({
                type : "POST", //提交方式
                url : "../sysTemplate/save",//路径
                contentType: "application/json;charset=utf-8",
                data : JSON.stringify(data.field),//数据，这里使用的是Json格式进行传输
                dataType: "json",
                success : function(result) {//返回数据根据结果进行相应的处理
                    if (result.code == "0") {
                        var index = layer.msg("成功", {
                            time: 300 //如果不配置，默认是3秒）
                        },function () {
                        	// 关闭弹出层
                            layer.close(index);
                            parent.layer.close(iframeIndex);
                        })
                    }else{
                        layer.msg(result.msg);
                    }
                }
            });
            return false;
        });
        
        //多选下拉框
        tableSelect.render({
            elem: '#tableSelect',
            searchKey: 'userName',
            checkedKey: 'memberId',
            searchPlaceholder: '请输入用户名',
            table: {
                url: '../sysMemberInfo/list',
                contentType: "application/json",
                method: 'POST',
                cols: [[
                    { type: 'checkbox' },
                    { field: 'memberId', title: 'ID',hide:true},
                    { field: 'userName', title: '用户名',align: "center"},
                    {field: 'roleName',title: '角色名称',align: "center"}
                ]]
            },
            done: function (elem, data) {
                var NEWJSON = []
                var selectTable="";
                var tableSelect="";
                layui.each(data.data, function (index, item) {
                    NEWJSON.push(item.userName);
                    tableSelect+=","+item.userName;
                    selectTable+=","+item.memberId;
                })
                elem.val(NEWJSON.join(","));
                $("#selectTable").val(selectTable);
                $("#tableSelects").val(tableSelect);
            }       
        });
        
      //地区联动
        form.on('select(quizarea1)', function(data){
   		 	LayuiCreateSelectArea("quizarea2","../area/getAreaList","",data.value);
   	 	});
   	 	form.on('select(quizarea2)', function(data){
   		 	LayuiCreateSelectArea("quizarea3","../area/getAreaList","",data.value);
   		});
   	 	form.on('select(quizarea3)', function(data){
		 	LayuiCreateSelectArea("quizarea4","../area/getAreaList","",data.value);
		});
   	 	
	   	 function LayuiCreateSelectArea(selectId, url, value,area_id) {//value  设置加载完成时所选定的值
	     	if(selectId=="quizarea2"&&area_id==""){
	     		$("#quizarea2").empty();//清空该元素
	     		$("#quizarea3").empty();//清空该元素
	     		$("#quizarea4").empty();
	     	}
	     	if(selectId=="quizarea3"&&area_id==""){
	     		$("#quizarea3").empty();//清空该元素
	     		$("#quizarea4").empty();
	     	}
	     	if(selectId=="quizarea4"&&area_id==""){
	     		$("#quizarea4").empty();
	     	}
	     	if(selectId=="quizarea2"){
	     		$("#quizarea3").empty();//清空该元素
	     		$("#quizarea4").empty();
	     	}
	     	if(selectId=="quizarea3"){
	     		$("#quizarea4").empty();//清空该元素
	     	}
	     	if(area_id!=""){
	     		//数据请求
	     	     $.ajax({
	     	          url:url,
	     	          type:'GET',
	     	          data:{areaId:area_id},
	     	          datatype:"json",
	     	          success:function(suc){
	     	        	  data=suc.data;
	     	        	//判断id是否有"#"
	     	        	  var select_id= selectId;
	     	              if (selectId.indexOf('#') != 0) {
	     	                  selectId = '#' + selectId;
	     	              }
	     	              $(selectId).empty();//清空该元素
	     	              //创建option
	 	              	$(selectId).append('<option value="">请选择</option>');
	     	              for (var k in data) {
	     	                  $(selectId).append("<option value='" + data[k].areaId + "'>" + data[k].areaName + "</option>");
	     	              }
	     	              //使用layui下拉框的必要代码
	     	              layui.use('form', function () {
	     	                  var form = layui.form;
	     	                  //设置选中值
	     	                  if (value != undefined && value != null && value != '') {
	     	                      $(selectId).val(value);
	     	                  }
	     	                  form.render('select');//重载表单
	     	              });
	     	          }
	     	      });
	     	}else{
	     		//使用layui下拉框的必要代码
	             layui.use('form', function () {
	                 var form = layui.form;
	                 form.render('select');//重载表单
	             });
	     	}
	   	 }

        //加载地图选取坐标
        $("#coordinates").on("click", function () {
     	   var index = layer.open({
                title: '地图',
                type: 1,
                shade: 0.2,
                maxmin:true,
                shadeClose: true,
                area: '500px',
                content:$('#maplocation'),
                btn: ['确定']
		     	,yes: function(index, layero){
		     		layer.close(index);
		     	},
                success:function(){
                     var map = new BMap.Map("maplocation"); // 创建地图实例

                    map.enableScrollWheelZoom();   //启用滚轮放大缩小，默认禁用
                    var point = new BMap.Point(113.31,32.72); // 创建点坐标
                    map.centerAndZoom(point, 12);

                   /*  function myFun(result){
                        var cityName = result.name;
                        map.setCenter(cityName);
                        //alert("当前定位城市:"+cityName);
                    }
                    var myCity = new BMap.LocalCity();
                    myCity.get(myFun); */


                    var marker = new BMap.Marker(map.getCenter());  // 创建标注
                    map.addOverlay(marker);               // 将标注添加到地图中
                    marker.enableDragging();                //可拖拽
                    //marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画


                    map.addEventListener("click",function(e){
                         // alert(e.point.lng+","+e.point.lat);// 单击地图获取坐标点；
                         $('#coordinates').val(e.point.lng+','+e.point.lat);
                         map.panTo(new BMap.Point(e.point.lng,e.point.lat));// map.panTo方法，把点击的点设置为地图中心点
                    });

                    marker.addEventListener("dragend", function(e){                    //拖拽标注获取标注坐标
                         //alert("当前位置：" + e.point.lng + ", " + e.point.lat);           //可拖拽的标注
                         //$('#coordinates').val(e.point.lng+','+e.point.lat);
                    })

                    //加载完成之后,改变标注点坐标,使之和当前定位的城市基本相符
                    map.addEventListener("tilesloaded",function(){
                        var newpoint = map.getCenter();
                        marker.setPosition(newpoint);
                    });
                 }
             });
        });
      /* //图片上传上传
        var uploadInst = upload.render({
            elem: '#test1'
            ,accept: 'images' //普通文件
            ,url: uploadurl+'/hnyfkj-file-server/common/upload' //改成您自己的上传接口
            ,before: function(obj){
            	loading= layer.msg('正在上传,请稍后', {icon: 16, shade: 0.3, time:0});
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){                	
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            ,choose: function(obj){
                var param = $('input[name="file"]')[0].value.toString();
                var params = param.split("\.");
                var name = params[0].split("\\");
				var iname = name[name.length-1].replace(/,/, "");
                this.data={name:name[name.length-1].replace(/,/, ""),type:"."+params[params.length-1],system:"im"}
                console.log(this.data);
            }
            ,data: {}
            ,done: function(res){
            	layer.close(loading);
                //如果上传失败
                $("#demoText1").val(uploadurl+"/"+res.result);
                if(res.code != 200){
                    return layer.msg('上传失败');
                }
                //上传成功
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText1');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });


        //图片上传上传
        var uploadInst = upload.render({
            elem: '#test2'
            ,accept: 'images' //普通文件
            ,url: uploadurl+'/hnyfkj-file-server/common/upload' //改成您自己的上传接口
            ,before: function(obj){
            	loading= layer.msg('正在上传,请稍后', {icon: 16, shade: 0.3, time:0});
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){                	
                    $('#demo2').attr('src', result); //图片链接（base64）
                });
            }
            ,choose: function(obj){
                var param = $('input[name="file"]')[1].value.toString();
                var params = param.split("\.");
                var name = params[0].split("\\");
				var iname = name[name.length-1].replace(/,/, "");
                this.data={name:iname,type:"."+params[params.length-1],system:"im"}
            }
            ,data: {}
            ,done: function(res){
            	layer.close(loading);
                //如果上传失败
                $("#demoText2").val(uploadurl+"/"+res.result);
                if(res.code != 200){
                    return layer.msg('上传失败');
                }
                //上传成功
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText2');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });


        //图片上传上传
        var uploadInst = upload.render({
            elem: '#test3'
            ,accept: 'images' //普通文件
            ,url: uploadurl+'/hnyfkj-file-server/common/upload' //改成您自己的上传接口
            ,before: function(obj){
            	loading= layer.msg('正在上传,请稍后', {icon: 16, shade: 0.3, time:0});
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){                	
                    $('#demo3').attr('src', result); //图片链接（base64）
                });
            }
            ,choose: function(obj){
                var param = $('input[name="file"]')[2].value.toString();
                var params = param.split("\.");
                var name = params[0].split("\\");
				var iname = name[name.length-1].replace(/,/, "");
                this.data={name:iname,type:"."+params[params.length-1],system:"im"}
                console.log(this.data);
            }
            ,data: {}
            ,done: function(res){
            	layer.close(loading);
                //如果上传失败
                $("#demoText3").val(uploadurl+"/"+res.result);
                if(res.code != 200){
                    return layer.msg('上传失败');
                }
                //上传成功
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText3');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });
        
        //删除图片
        $(document).on("mouseenter mouseleave", ".file-iteme", function(event){
            if(event.type === "mouseenter"){
                //鼠标悬浮
                $(this).children(".info").fadeIn("fast");
                $(this).children(".handle").fadeIn("fast");
            }else if(event.type === "mouseleave") {
                //鼠标离开
                $(this).children(".info").hide();
                $(this).children(".handle").hide();
            }
        });
      
     	// 删除图片
        $(document).on("click", "#handle1", function(event){
        	$('#demo1').attr('src', "");
        	$('#demoText1').val("");
        });
     	
        $(document).on("click", "#handle2", function(event){
        	$('#demo2').attr('src', "");
        	$('#demoText2').val("");  
        });
     
        $(document).on("click", "#handle3", function(event){
        	$('#demo3').attr('src', "");
        	$('#demoText3').val(""); 
        });*/
        
      //上传图片关键方法         		
    	$("#case").upload()
                    
        //富文本
        var editor = new wangEditor('#editor');
        editor.customConfig.uploadImgServer = "../sysTemplate/ueditor";
        editor.customConfig.uploadFileName = 'file';
        editor.customConfig.pasteFilterStyle = false;
        editor.customConfig.uploadImgMaxLength = 5;
        editor.customConfig.uploadImgHooks = {
            // 上传超时
            timeout: function (xhr, editor) {
                layer.msg('上传超时！')
            },
            // 如果服务器端返回的不是 {errno:0, data: [...]} 这种格式，可使用该配置
            customInsert: function (insertImg, result, editor) {
                console.log(result);
                if (result.code == 1) {
                    var url = result.data.url;
                    url.forEach(function (e) {
                        insertImg(e);
                    })
                } else {
                    layer.msg(result.msg);
                }
            }
        };
        editor.customConfig.customAlert = function (info) {
            layer.msg(info);
        };
        editor.create();
   
        $('#cancel').on("click", function () {
            parent.layer.close(iframeIndex);
       });
   });
</script>
</body>
</html>